package com.googlecode.microanalyst.palette.model;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.swt.graphics.Image;

import com.googlecode.microanalyst.designer.model.AnalysisElement;
import com.googlecode.microanalyst.designer.model.property.PropertyHandler;
import com.googlecode.microanalyst.palette.i18n.PaletteMessages;

public class LabeledConnection extends AnalysisElement {

	private static final long serialVersionUID = 1L;

	public static final String ICON_PATH = "icons/label-connection16.gif";//$NON-NLS-1$

	public static Image ICON = createImage(Smooth.class, ICON_PATH);

	private String label = "";

	public LabeledConnection() {
		size.width = -1;
		size.height = -1;
	}

	protected LabeledConnection(String label) {
		this();
		this.label = label;
	}

	@Override
	public Image getIconImage() {
		return ICON;
	}

	@Override
	public Dimension getSize() {
		return new Dimension(size.width, size.height);
	}
	
	@Override
	public void setSize(Dimension size) {
	}

	@Override
	public String toString() {
		return PaletteMessages.Palette_Tool_LabeledConnection;
	}

	@Override
	public Object clone() {
		return new LabeledConnection(label);
	}

	@Override
	public PropertyHandler getPropertyHandler() {
		return new LabeledConnectionProperties(this);
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		String old = this.label;
		this.label = label;
		firePropertyChange("text", old, label); //$NON-NLS-1$
	}

}
